clear all
set emptycells drop
set matsize 11000
set maxvar 32670

*Set working directory
if c(username)=="" { //insert username
cd "" // insert root path
}

if c(username)=="jonathancolmer" { 
	cd "/Users/jonathancolmer/The Lab Dropbox/Jonathan Colmer/ShotSpotter_env/Journal_submissions/ReStat/Replication Folder" 
}

if c(username)=="jmc4qg" { 
	cd "/Users/jmc4qg/The Lab Dropbox/Jonathan Colmer/ShotSpotter_env/Journal_submissions/ReStat/Replication Folder" 
}

import delimited "Figures and Tables/Figure_3/Figure_3_data.csv", encoding(ISO-8859-1) clear
gen n = _n 
drop if n > 17
drop if n == 1
drop if n == 17
gen year = n
replace year = year - 7
replace year = year - 1 if year < 0
set obs 16
replace year = -1 in 16
replace estimate = 0 in 16
replace stderror = 0 in 16
sort year

gen lower = estimate - (1.96*stderr)
gen upper = estimate + (1.96*stderr)

gen lower10 = estimate - (1.64*stderr)
gen upper10 = estimate + (1.64*stderr)


twoway(rarea lower upper year if year >= -6 & year <=9, col(black) fint(20) lwidth(0))(line estimate year if year >= -6 & year <=9, lcol(black))(lfit estimate year if year <= -1, lpattern(dash) lcolor(black))(lfit estimate year if year >= -1, lpattern(dash) lcolor(black)), yline(0) graphregion(fcolor(white)) legend(off)  graphregion(lcolor(255 255 255)) xlab(-6(1)9) xline(-1, lwidth(med) lpattern(solid)) xtitle("Year (Relative to RTC Implementation)") ytitle("Estimate")
graph export "Figures and Tables/Figure_3/Figure_3.png",replace
